package cn.demographic.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import cn.demographic.entity.Housecategory;
import cn.demographic.entity.Houseleixing;
import cn.demographic.entity.Livepatten;
import cn.demographic.entity.Livingreasons;
import cn.demographic.entity.Pregnancy;
import cn.demographic.entity.Relationship;
import cn.demographic.entity.Usage;
import cn.demographic.entity.Workingconditions;

import cn.demographic.service.UserInformationService;

import cn.demographic.service.EmploymentService;
import cn.demographic.service.HousecategoryService;
import cn.demographic.service.HouseleixingService;
import cn.demographic.service.LivepattenService;
import cn.demographic.service.LivingreasonsService;
import cn.demographic.service.ProvinceCityCountyService;
import cn.demographic.service.UsageService;
import cn.demographic.service.WorkingconditionsService;

@RestController
@RequestMapping("/DataTable")
public class DataTableController {
	@Autowired
	private ProvinceCityCountyService provinceCityCountyService;
	@Autowired
	private UserInformationService userInformationService;
	//从业状况的业务层
	@Autowired
	private WorkingconditionsService workingconditionsService;
	@Autowired
	private EmploymentService employmentService;
	@Resource
	private LivepattenService livepattenService;
	@Resource
	private LivingreasonsService livingreasonsService;
	@Resource
	private HousecategoryService housecategoryService;
	@Resource
	private HouseleixingService houseleixingService;
	@Resource
	private UsageService usageService;
	/**
	 * 展示省市县下拉框数据方法
	 * @return
	 */
	@RequestMapping("/findAddress")
	@ResponseBody
	public Map<String,Object> findAddress() {
		Map<String,Object> map = provinceCityCountyService.find();
		return map;
	}
	
	/**
	 * 添加个人信息页面，展示数据
	 * @return
	 */
	@RequestMapping("/findPersonalInformationDisplay")
	@ResponseBody
	public Map<String,Object> findPersonalInformationDisplay() {
		Map<String,Object> map = userInformationService.find();
		return map;
	}
	/**
	 * 添加就业信息页面,展示数据
	 * @return
	 */
	@RequestMapping("/findAddemployment")
	@ResponseBody
	public Map<String,Object> findAddemployment(){
		Map<String,Object> map =employmentService.find();
		return map;
	}
	
	/**
	 * 查询所有的从业状况
	 * @return
	 */
	@RequestMapping("/selectWork")
	@ResponseBody
	public Map<String,Object> selectWork(){
		Map<String,Object> map = new HashMap<String, Object>();
		List<Workingconditions> work = workingconditionsService.selectWork();
		map.put("work", work);
		return map;	
	}
	
	/**
	 * 查询所有的怀孕避孕
	 * @return
	 */
	@RequestMapping("/selecPregnancy")
	@ResponseBody
	public Map<String,Object> selecPregnancy(){
		Map<String,Object> map = new HashMap<String, Object>();
		List<Pregnancy> pregnancy = workingconditionsService.selectPregnancy();
		map.put("pregnancy", pregnancy);
		return map;	
	}

	/**
	 * 查询家庭关系信息
	 * @return
	 */
	@RequestMapping("/findRelationship")
	@ResponseBody
	public List<Relationship> findRelationship() {
		List<Relationship> relationships = workingconditionsService.findRelationship();
		return relationships;
	}
	/**
	 * 居住方式
	 * @return
	 */
	@RequestMapping("/getlivepattenlist")
	@ResponseBody
	public Map<String,Object> getlivepattenlist(){
		Map<String,Object> map = new HashMap<String, Object>();
		List<Livepatten>livepattenlist=livepattenService.getlivepattenlist();
		map.put("livepattenlist", livepattenlist);
		return map;
	}
	/**
	 * 居住原因
	 * @return
	 */
	
	@RequestMapping("/getlivingreasonslist")
	@ResponseBody
	public Map<String,Object> getlivingreasonslist(){
		Map<String,Object> map = new HashMap<String, Object>();
		List<Livingreasons>livingreasonslist=livingreasonsService.getlivingreasonslist();
		map.put("livingreasonslist", livingreasonslist);
		return map;
	}
	/**
	 * 房屋类别
	 * @return
	 */
	@RequestMapping("/gethousecategorylist")
	@ResponseBody
	public Map<String,Object> gethousecategorylist(){
		Map<String,Object> map = new HashMap<String, Object>();
		List<Housecategory>housecategorylist=housecategoryService.gethousecategorylist();
		map.put("housecategorylist", housecategorylist);
		return map;
	}
	/**
	 * 房屋类型
	 * @return
	 */
	@RequestMapping("/gethouseleixinglist")
	@ResponseBody
	public Map<String,Object> gethouseleixinglist(){
		Map<String,Object> map = new HashMap<String, Object>();
		List<Houseleixing>houseleixinglist=houseleixingService.gethouseleixinglist();
		map.put("houseleixinglist", houseleixinglist);
		return map;
	}
	/**
	 * 房屋用途
	 * @return
	 */
	@RequestMapping("/getusagelist")
	@ResponseBody
	public Map<String,Object> getusagelist(){
		Map<String,Object> map = new HashMap<String, Object>();
		List<Usage>usagelist=usageService.getusagelist();
		map.put("usagelist", usagelist);
		return map;
	}
}
